<template>
	<view class="content">
		<view class="box">
			<view class="box1">
				<text>用户名</text>
				<text class="you">{{mobile}}</text>
			</view>
		</view>
		<view class="box">
			<view class="box1">
				<text>昵称</text>
				<text class="you">{{username}}</text>
			</view>
		</view>
		<view class="box">
			<view class="box1">
				<text>我的邀请码</text>
				<text class="you">{{tj_code}}</text>
			</view>
		</view>
		<!-- <view class="box">
			<view class="box1">
				<text>是否开启自动化划转</text>
				<switch :checked="open" @change="switch2Change" />
			</view>
		</view> -->
		<view class="box">
			<view class="box1">
				<text>当前版本号</text>
				<view class="you">{{current_versions}} <image src="../../../static/icon/zuojiantou.png" mode=""></image></view>
			</view>
		</view>
		<view class="mybtn" @tap="logout">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				open:false,
				current_versions:'',
				tj_code:'',
				username:'',
				mobile:'',
				
			}
		},
		onShow() {
			this.getinfo()
		},
		methods: {
			getinfo(){
				var token =uni.getStorageSync('token')
				if(token==''||token==null){
					uni.reLaunch({
					    url:'../../login/login'
					})
				}else{
					this.http({
					 	url:'/api/User/my_set',
					 	method:'POST',
						header:{
							'token':token
						},
					 	success:(res)=>{
							console.log(res)
							this.current_versions= res.data.current_versions
							this.mobile= res.data.mobile
							this.username= res.data.username
							this.tj_code= res.data.tj_code
						},
					 	error:()=>{
					 		uni.showToast({
					 			title:"请求异常"	
					 		})
					 	},	
					 })
				} 
			},
			switch2Change: function (e) {
			    console.log('switch2 发生 change 事件，携带值为', e.target.value)
			      },
			logout(){
				uni.showModal({
					 title: '提示',
					    content: '确认退出APP吗？',
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								uni.removeStorage({
									key:'token'
								})
								uni.reLaunch({
									url:'../../login/login'
								})
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					
				})
				
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC;
		font-weight: 500;
		color:#2b2b2b;
		padding-bottom: 50rpx;
		.box{
			width: 690rpx;
			height: 118rpx;
			background: #FFFFFF;
			box-shadow: 0px 0px 2px 0px rgba(43, 43, 43, 0.18);
			border-radius: 10rpx;
			margin: 25rpx auto;
			.box1{
				width: 620rpx;
				height: 118rpx;
				margin:0  auto;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 30rpx;
				.you{
					color: #CCCCCC;
					display: flex;
					align-items: center;
					image{
						width: 40rpx;
						height: 40rpx;
					}
				}
			}
		}
		.mybtn{
			width: 690rpx;
			height: 98rpx;
			background: #0072FF;
			border-radius: 49rpx;
			font-size: 36rpx;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 98rpx;
			margin: 67rpx auto;
			text-align: center;
		}
	}

	
</style>
